<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('简历详情')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
<form class="form-horizontal m" id="form-recruitment">
    <div class="row">
        <input id="recruitmentId" th:value="${recruitmentId}" type="hidden">
        <label class="col-sm-2 control-label">
            简历：
        </label>
        <div class="col-sm-10 form-group">
            <select id="resume" class="form-control" data-first-option="false"
                    data-live-search="true" onclick="getAllResume()"></select>
        </div>
    </div>
</form>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/recruitment";
        $(function () {
            getAllResume();
        })
        //获取用户所有简历信息
        function getAllResume() {
            var request = {
                url: prefix + "/getAllResume",
                type: "post",
                dataType: "json",
                success: function (result) {
                    let length = result.data.length;
                    var str = "";
                    for (let i = 0; i < length; i++) {
                        str = str + "<option value=\"" + result.data[i] + "\">" + "简历" + result.data[i] + "</option>";
                    }
                    $("#resume").empty();
                    $("#resume").append(str);
                    $('#resume').selectpicker("refresh");
                    $('#resume').selectpicker("render");
                }
            };
            $.ajax(request);
        }

        function submitHandler() {
            if ($.validate.form()) {
                var data = $("#form-recruitment").serializeArray();
                var recruitmentId = $("#recruitmentId").val();
                var resumeId = $("#resume").val();
                data.push({"name": "recruitmentId", "value": recruitmentId});
                data.push({"name": "resumeId", "value": resumeId});
                $.operate.save(prefix + "/giveRecruitment", data);
            }
        }
    </script>
</body>
</html>
